from flask import Flask, request, jsonify
from douyin_life_refer_order_data import *
app = Flask(__name__)



@app.route('/dy_life/order_refer', methods=['GET','POST'])
def process_data():
    # try:
    if request.method == 'POST':
        data = request.get_json()
        random = data["random"]
        account_id = data["account_id"]
        order_id = data.get('order_id',[])
        print(order_id)
        res = DOUYIN_LIFE(str(random),account_id, order_id)
        result_data = res.dy_creator_center_spider()
        # print(random)
        # print(result_data)
        # print(result_data)
        return {"code":200,"msg":"数据返回成功","data":result_data}
    else:
        pass

    # else:
    #     user_id = request.args["user_id"]
    #     res = DOUYIN_LIFE(str(user_id))
    #     result_data = res.dy_creator_center_spider()
    #     return result_data
    # except:
    #     return {"msg":"未传参数","code":"500"}


if __name__ == '__main__':

    app.run(host='0.0.0.0',port=5003,threaded=True)
